package com.hm.pan.service.impl;

import java.io.File;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.hm.pan.mapper.FileInfoMapper;
import com.hm.pan.model.FileInfo;
import com.hm.pan.service.FileInfoService;

@Service
public class FileInfoServiceImpl implements FileInfoService {

	@Resource
	private FileInfoMapper fileInfoMapper;

	@Override
	public FileInfo getFileInfo(FileInfo filter) throws Exception {
		return fileInfoMapper.getFileInfo(filter);
	}

	@Override
	public File getFile(FileInfo filter) throws Exception {
		FileInfo fileInfo = this.getFileInfo(filter);

		if (fileInfo == null) {
			return null;
		}

		return new File(fileInfo.getFilePath());
	}

	@Override
	public boolean insertFileInfo(FileInfo fileInfo) {
		return fileInfoMapper.insertFileInfo(fileInfo);
	}

}
